package me.zingon.self.bigdispatcher.dto;

import lombok.Data;

/**
 * @author ztc 1423047407@qq.com
 * @version 1.0
 * @date 2021-1-5 09:16
 */
@Data
public class R<T> {

    Integer code;

    String msg;

    T data;

    public static final <T> R success(){
        R<T> r=new R<>();
        r.setCode(0);
        return r;
    }

    public static final <T> R success(T data){
        R<T> r=new R<>();
        r.setCode(0);
        r.setData(data);
        return r;
    }

    public static final <T> R success(Integer code, T data){
        R<T> r=new R<>();
        r.setCode(code);
        r.setData(data);
        return r;
    }

    public static final <T> R failed(String msg){
        R<T> r=new R<>();
        r.setCode(-2);
        r.setMsg(msg);
        return r;
    }

}
